package com.dede.getmusic.base

import android.os.Bundle
import android.support.annotation.LayoutRes
import android.support.v7.app.AppCompatActivity
import com.lzy.okgo.OkGo
import org.jetbrains.anko.toast

/**
 * @author hsh
 * @date 2017/10/12 14:11.
 * @doc
 */
abstract class BaseActivity : AppCompatActivity(), IBaseView {

    protected val TAG = javaClass.simpleName

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(getLayoutId())

        initView()

        initData()
    }

    protected open fun initData() {

    }

    protected abstract fun initView()

    @LayoutRes
    protected abstract fun getLayoutId(): Int

    override fun onDestroy() {
        super.onDestroy()
        OkGo.getInstance().cancelTag(this)
    }

    override fun showToast(msg: String) {
        toast(msg)
    }

    override fun context() = this
}
